package com.qwc.blog.entity.vo.resource;

import com.qwc.blog.common.validate.IdValid;
import com.qwc.blog.entity.Resource;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 * @author qwc
 * @Date 2021/10/27 16:03
 */
@Data
public class ResourceDto {
    @NotNull(groups = IdValid.class, message = "资源主键不能为空")
    private Long resId;
    @NotBlank(message = "资源名称不能为空")
    @Size(min = 0, max = 50, message = "资源名称长度不能超过50个字符")
    private String resName;
    @Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符")
    private String permKey;
    @Size(min = 0, max = 200, message = "路由地址不能超过200个字符")
    private String path;
    @Size(min = 0, max = 200, message = "组件路径不能超过255个字符")
    private String component;
    private String icon;
    @NotNull(message = "显示顺序不能为空")
    private Integer orderNum;
    private Long pid;
    @NotBlank(message = "资源类型不能为空")
    private String resType;
    private Integer isFrame;
    private Integer isCache;
    private String visible;
    private String status;

    public Resource createResource() {
        Resource resource = new Resource();
        resource.setResId(resId);
        resource.setResName(resName);
        resource.setPermKey(permKey);
        resource.setPath(path);
        resource.setComponent(component);
        resource.setOrderNum(orderNum);
        resource.setResType(resType);
        resource.setIsFrame(isFrame);
        resource.setPid(pid);
        resource.setIsCache(isCache);
        resource.setVisible(visible);
        resource.setStatus(status);
        resource.setIcon(icon);
        return resource;
    }
}
